import LinkedListQueue.Queue;
import TreeTraversal.TreeNode;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class levelOrder {
    List<List<Integer>> res = new ArrayList<>();
    public List<List<Integer>> levelOrder(TreeNode root) {
        a(root,0);
        return res;
    }
    public void a(TreeNode root,Integer depth){
        if(root == null){
            return;
        }
        depth++;
        if(res.size() < depth){
            List<Integer> list = new ArrayList<>();
            res.add(list);
        }
        res.get(depth-1).add(root.val);
        a(root.left,depth);
        a(root.right,depth);

    }
}
